program minmax;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, j, q: integer;
  fin: textfile;
  a: array of integer;

begin
  assignfile(fin, 'input.txt');
  reset(fin);
  readln(fin, n);
  setlength(a, n);
    for i:=1 to n do
    begin
      read(fin, a[i]);
    end;
    for j:= 1 to n do
      for i:=0 to n-j do
        if (a[i]>a[i+1]) then
        begin
          q:=a[i];
          a[i]:=a[i+1];
          a[i+1]:=q;
        end;
  writeln(a[1]+a[n]);
  readln;
  closefile(fin);
end.
 